<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>讨论页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../static/assets/libs/layui/css/layui.css" th:href="@{/assets/libs/layui/css/layui.css}"/>
    <link rel="stylesheet" href="../../static/assets/css/style.css" th:href="@{/assets/css/style.css}"/>
    <link rel="stylesheet" href="../../static/assets/css/css.css" th:href="@{/assets/css/css.css}"/>
    <link rel="stylesheet" href="../../static/assets/css/global.css" th:href="@{/assets/css/global.css}"/>
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../static/css/typo.css" th:href="@{/css/typo.css}"/>
    <link rel="stylesheet" href="../static/css/animate.css" th:href="@{/css/animate.css}"/>
    <link rel="stylesheet" href="../static/lib/prism/prism.css" th:href="@{/lib/prism/prism.css}"/>
    <link rel="stylesheet" href="../static/lib/tocbot/tocbot.css" th:href="@{/lib/tocbot/tocbot.css}"/>
    <link rel="stylesheet" href="../static/css/me.css" th:href="@{/css/me.css}"/>
</head>
<body>
<!-- 顶部 -->
<div th:include="common :: headname"></div>
<div class="course_body">
    <div class="w1220 course_nav">
	        <span class="layui-breadcrumb">
	            <a href="/">首页</a>
	            <a href="javascript:;">讨论</a>
	        </span>
    </div>
    <div class="w1220 course_intro1">
        <h3>课题：</h3>
        [[${discuss.topic}]]
    </div>

    <div class="w1220 course_content">
        <!--评论-->
        <div class="ui bottom attached segment">

            <div>
                <div id="comment-container" class="ui teal segment">
                    <div class="ui comments" style="max-width: 100%">
                        <h3 class="ui dividing header">评论</h3>

                        <div th:each="item:${comments}">
                            <div class="comment">
                                <a class="avatar">
                                    <img th:src="${item.userId.avatar}">
                                </a>
                                <div class="content">
                                    <a class="author" th:text="${item.userId.userName}">Matt</a>
                                    <div class="metadata">
                                        <span class="date"
                                              th:text="${#dates.format(item.createTime,'yyyy-MM-dd HH-mm')}">今天下午 5:42</span>
                                    </div>
                                    <div class="text" th:text="${item.content}">太赞了！</div>
                                    <div class="actions">
                                        <a class="reply" data-commentid="1" data-commentnickname="Matt"
                                           th:attr="data-commentid=${item.id},data-commentnickname=${item.userId.userName}"
                                           onclick="reply(this)">回复</a>
                                    </div>
                                </div>

                                <div class="comments" th:if="${#arrays.length(item.comments)}>0">
                                    <div class="comment" th:each="reply:${item.comments}">
                                        <a class="avatar">
                                            <img th:src="${reply.userId.avatar}">
                                        </a>
                                        <div class="content">
                                            <a class="author">
                                                <span th:text="${reply.userId.userName}">json</span><span
                                                    th:text="|@ ${reply.parentComment.userId.userName}|"></span>
                                            </a>
                                            <div class="metadata">
                                                <span class="date"
                                                      th:text="${#dates.format(reply.createTime,'yyyy-MM-dd HH-mm')}">刚刚</span>
                                            </div>
                                            <div class="text" th:text="${reply.content}">艾略特你永远是多么正确 :)</div>
                                            <div class="actions">
                                                <a class="reply" data-commentid="1" data-commentnickname="Matt"
                                                   th:attr="data-commentid=${reply.id},data-commentnickname=${reply.userId.userName}"
                                                   onclick="reply(this)">回复</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>


                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <!-- 留言评论表单-->
        <form class="layui-form" th:action="@{/comment/comments}" method="post">
<!--            <input type="hidden" name="user.id" th:value="${discuss.user.id}">&lt;!&ndash;获取博客id，用于添加&ndash;&gt;-->
<!--            <input type="hidden" name="discuss.id" th:value="${discuss.id}">&lt;!&ndash;获取博客id，用于添加&ndash;&gt;-->
<!--            <input type="hidden" name="parentComment.id" value="-1">&lt;!&ndash;获取父评论id，点击回复后由reply()设置&ndash;&gt;-->

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">评论：</label>
                <div class="layui-input-block">
                    <textarea name="content" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="text" name="discussId" th:value="${discuss.id}" required  lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input id="parentComment" type="text" name="parentComment" value="0" required  lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block" th:if="${session.userLogin}?true:false">
                    <input type="text" name="userId" th:value="${session.userLogin.id}" required  lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                </div>
            </div>

        </form>
    </div>
</div>

<!-- js部分 -->
<div class="fly-footer">
    <p><a href="http://fly.layui.com/" target="_blank">Fly社区</a> 2021 &copy; <a href="http://www.layui.com/" target="_blank">layui.com 出品</a></p>
    <p>
        <a href="http://fly.layui.com/jie/3147/" target="_blank">付费计划</a>
        <a href="http://www.layui.com/template/fly/" target="_blank">获取Fly社区模版</a>
        <a href="http://fly.layui.com/jie/2461/" target="_blank">微信公众号</a>
    </p>
</div>
<script type="text/javascript" src="../../static/assets/libs/layui/layui.js" th:src="@{/assets/libs/layui/layui.js}"></script>
<script type="text/javascript" src="../../static/assets/js/common.js" th:src="@{/assets/js/common.js}"></script>
<script th:src="@{'https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js'}"></script>
<script th:src="@{'https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js'}"></script>
<script th:src="@{'//cdn.jsdelivr.net/npm/jquery.scrollto@2.1.2/jquery.scrollTo.min.js'}"></script>
<script th:src="@{/lib/prism/prism.js}"></script>
<script th:src="@{/lib/tocbot/tocbot.min.js}"></script>
<script th:src="@{/lib/qrcode/qrcode.min.js}"></script>
<script th:src="@{/lib/waypoints/jquery.waypoints.min.js}"></script>
<script>


    tocbot.init({
        // Where to render the table of contents.
        tocSelector: '.js-toc',
        // Where to grab the headings to build the table of contents.
        contentSelector: '.js-toc-content',
        // Which headings to grab inside of the contentSelector element.
        headingSelector: 'h1, h2, h3',
        // For headings inside relative or absolute positioned containers within content.
        hasInnerContainers: true,
    });
    var waypoint = new Waypoint({
        element: document.getElementById('waypoint'),
        handler: function (direction) {
            if (direction == 'down') {
                $('#toolbar').show(500);
            } else {
                $('#toolbar').hide(500);
            }
            console.log('Scrolled to waypoint!')
        }
    });
    function reply(obj) {
        var commentId = $(obj).data('commentid');
        var commentNickname = $(obj).data("commentnickname");
        $("[name='content']").attr("placeholder", "@" + commentNickname).focus();
        $("[name='parentComment']").val(commentId);
    }


</script>
</body>
</html>